<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickpinchhandler.cpp -->
  <title>PinchHandler QML 类型 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-qmlmodule.html">QML类型</a></td><td >PinchHandler QML 类型</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#properties">属性</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">PinchHandler QML 类型</h1>
<span class="subtitle"></span>
<!-- $$$PinchHandler-brief -->
<p>Handler for pinch gestures. <a href="#details">更多...</a></p>
<!-- @@@PinchHandler -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> 导入语句：</td><td class="memItemRight bottomAlign"> import QtQuick 2.12</td></tr><tr><td class="memItemLeft rightAlign topAlign">继承自：</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-multipointhandler.html">MultiPointHandler</a></p>
</td></tr></table></div><ul>
<li><a href="qml-qtquick-pinchhandler-members.html">所有成员的列表，包括继承成员</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">属性</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#active-prop">active</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#activeScale-prop">activeScale</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#centroid-prop">centroid</a></b></b> : QtQuick::HandlerPoint</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#maximumRotation-prop">maximumRotation</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#maximumScale-prop">maximumScale</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#minimumRotation-prop">minimumRotation</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#minimumScale-prop">minimumScale</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#minimumTouchPoints-prop">minimumTouchPoints</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#rotation-prop">rotation</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#scale-prop">scale</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#translation-prop">translation</a></b></b> : QVector2D</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#xAxis-prop">xAxis</a></b></b><ul>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#xAxis.minimum-prop">xAxis.minimum</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#xAxis.maximum-prop">xAxis.maximum</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#xAxis.enabled-prop">xAxis.enabled</a></b></b> : bool</li>
</ul>
</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#yAxis-prop">yAxis</a></b></b><ul>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#yAxis.minimum-prop">yAxis.minimum</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#yAxis.maximum-prop">yAxis.maximum</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pinchhandler.html#yAxis.enabled-prop">yAxis.enabled</a></b></b> : bool</li>
</ul>
</li>
</ul>
<!-- $$$PinchHandler-description -->
<a name="details"></a>
<h2 id="details">详细信息</h2>
<p><a href="qml-qtquick-pinchhandler.html">PinchHandler</a> is a handler that interprets a multi-finger gesture to interactively rotate, zoom, and drag an Item. Like other Input Handlers, by default it is fully functional, and manipulates its <a href="../qmake/qmake-variable-reference.html#target">target</a>, which is the Item within which it is declared.</p>
<pre class="qml">

  import QtQuick 2.12

  <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
      <span class="name">width</span>: <span class="number">400</span>
      <span class="name">height</span>: <span class="number">300</span>
      <span class="name">color</span>: <span class="string">&quot;lightsteelblue&quot;</span>
      <span class="type"><a href="qml-qtquick-pinchhandler.html">PinchHandler</a></span> { }
  }

</pre>
<p>It has properties to restrict the range of dragging, rotation, and zoom.</p>
<p>If it is declared within one Item but is assigned a different <a href="../qmake/qmake-variable-reference.html#target">target</a>, it handles events within the bounds of the outer Item but manipulates the <code>target</code> Item instead:</p>
<pre class="qml">

  import QtQuick 2.12

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="name">width</span>: <span class="number">640</span>
      <span class="name">height</span>: <span class="number">480</span>

      <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
          <span class="name">id</span>: <span class="name">map</span>
          <span class="name">color</span>: <span class="string">&quot;aqua&quot;</span>
          <span class="name">width</span>: <span class="number">400</span>
          <span class="name">height</span>: <span class="number">300</span>
      }

      <span class="type"><a href="qml-qtquick-pinchhandler.html">PinchHandler</a></span> {
          <span class="name">target</span>: <span class="name">map</span>
      }
  }

</pre>
<p>A third way to use it is to set <a href="../qmake/qmake-variable-reference.html#target">target</a> to <code>null</code> and react to property changes in some other way:</p>
<pre class="qml">

  import QtQuick 2.12

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="name">width</span>: <span class="number">640</span>
      <span class="name">height</span>: <span class="number">480</span>

      <span class="type"><a href="qml-qtquick-pinchhandler.html">PinchHandler</a></span> {
          <span class="name">id</span>: <span class="name">handler</span>
          <span class="name">target</span>: <span class="number">null</span>
      }

      <span class="type"><a href="qml-qtquick-text.html">Text</a></span> {
          <span class="name">color</span>: <span class="name">handler</span>.<span class="name">active</span> ? <span class="string">&quot;darkgreen&quot;</span> : <span class="string">&quot;black&quot;</span>
          <span class="name">text</span>: <span class="name">handler</span>.<span class="name">rotation</span>.<span class="name">toFixed</span>(<span class="number">1</span>) <span class="operator">+</span> <span class="string">&quot; degrees\n&quot;</span> <span class="operator">+</span>
                <span class="name">handler</span>.<span class="name">translation</span>.<span class="name">x</span>.<span class="name">toFixed</span>(<span class="number">1</span>) <span class="operator">+</span> <span class="string">&quot;, &quot;</span> <span class="operator">+</span> <span class="name">handler</span>.<span class="name">translation</span>.<span class="name">y</span>.<span class="name">toFixed</span>(<span class="number">1</span>) <span class="operator">+</span> <span class="string">&quot;\n&quot;</span> <span class="operator">+</span>
                (<span class="name">handler</span>.<span class="name">scale</span> <span class="operator">*</span> <span class="number">100</span>).<span class="name">toFixed</span>(<span class="number">1</span>) <span class="operator">+</span> <span class="string">&quot;%&quot;</span>
      }
  }

</pre>
<p class="centerAlign"><img src="images/touchpoints-pinchhandler.png" alt="" /></p><p><b>See also </b><a href="qml-qtquick-pincharea.html">PinchArea</a>.</p>
<!-- @@@PinchHandler -->
<h2>属性文档</h2>
<!-- $$$active -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="active-prop">
<td class="tblQmlPropNode"><p>
<a name="active-prop"></a><span class="name">active</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property is true when all the constraints (epecially <a href="qml-qtquick-pinchhandler.html#minimumTouchPoints-prop">minimumTouchPoints</a>) are satisfied and the <a href="../qmake/qmake-variable-reference.html#target">target</a>, if any, is being manipulated.</p>
</div></div><!-- @@@active -->
<br/>
<!-- $$$activeScale -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="activeScale-prop">
<td class="tblQmlPropNode"><p>
<a name="activeScale-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">activeScale</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The scale factor while the pinch gesture is being performed. It is 1.0 when the gesture begins, increases as the touchpoints are spread apart, and decreases as the touchpoints are brought together. If <a href="../qmake/qmake-variable-reference.html#target">target</a> is not null, its <a href="qml-qtquick-item.html#scale-prop">scale</a> will be automatically multiplied by this value. Otherwise, bindings can be used to do arbitrary things with this value.</p>
</div></div><!-- @@@activeScale -->
<br/>
<!-- $$$centroid -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="centroid-prop">
<td class="tblQmlPropNode"><p>
<a name="centroid-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">centroid</span> : <span class="type"><a href="qml-qtquick-handlerpoint.html">QtQuick::HandlerPoint</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>A point exactly in the middle of the currently-pressed touch points. The <a href="../qmake/qmake-variable-reference.html#target">target</a> will be rotated around this point.</p>
</div></div><!-- @@@centroid -->
<br/>
<!-- $$$maximumRotation -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="maximumRotation-prop">
<td class="tblQmlPropNode"><p>
<a name="maximumRotation-prop"></a><span class="name">maximumRotation</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The maximum acceptable <a href="qml-qtquick-item.html#rotation-prop">rotation</a> to be applied to the <a href="../qmake/qmake-variable-reference.html#target">target</a>.</p>
</div></div><!-- @@@maximumRotation -->
<br/>
<!-- $$$maximumScale -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="maximumScale-prop">
<td class="tblQmlPropNode"><p>
<a name="maximumScale-prop"></a><span class="name">maximumScale</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The maximum acceptable <a href="qml-qtquick-item.html#scale-prop">scale</a> to be applied to the <a href="../qmake/qmake-variable-reference.html#target">target</a>.</p>
</div></div><!-- @@@maximumScale -->
<br/>
<!-- $$$minimumRotation -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="minimumRotation-prop">
<td class="tblQmlPropNode"><p>
<a name="minimumRotation-prop"></a><span class="name">minimumRotation</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The minimum acceptable <a href="qml-qtquick-item.html#rotation-prop">rotation</a> to be applied to the <a href="../qmake/qmake-variable-reference.html#target">target</a>.</p>
</div></div><!-- @@@minimumRotation -->
<br/>
<!-- $$$minimumScale -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="minimumScale-prop">
<td class="tblQmlPropNode"><p>
<a name="minimumScale-prop"></a><span class="name">minimumScale</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The minimum acceptable <a href="qml-qtquick-item.html#scale-prop">scale</a> to be applied to the <a href="../qmake/qmake-variable-reference.html#target">target</a>.</p>
</div></div><!-- @@@minimumScale -->
<br/>
<!-- $$$minimumTouchPoints -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="minimumTouchPoints-prop">
<td class="tblQmlPropNode"><p>
<a name="minimumTouchPoints-prop"></a><span class="name">minimumTouchPoints</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The pinch begins when this number of fingers are pressed. Until then, <a href="qml-qtquick-pinchhandler.html">PinchHandler</a> tracks the positions of any pressed fingers, but if it's an insufficient number, it does not scale or rotate its <a href="../qmake/qmake-variable-reference.html#target">target</a>, and the <a href="qml-qtquick-pinchhandler.html#active-prop">active</a> property will remain false.</p>
</div></div><!-- @@@minimumTouchPoints -->
<br/>
<!-- $$$rotation -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="rotation-prop">
<td class="tblQmlPropNode"><p>
<a name="rotation-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">rotation</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The rotation of the pinch gesture in degrees, with positive values clockwise. It is 0 when the gesture begins. If <a href="../qmake/qmake-variable-reference.html#target">target</a> is not null, this will be automatically applied to its <a href="qml-qtquick-item.html#rotation-prop">rotation</a>. Otherwise, bindings can be used to do arbitrary things with this value.</p>
</div></div><!-- @@@rotation -->
<br/>
<!-- $$$scale -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="scale-prop">
<td class="tblQmlPropNode"><p>
<a name="scale-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">scale</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The scale factor that will automatically be set on the <a href="../qmake/qmake-variable-reference.html#target">target</a> if it is not null. Otherwise, bindings can be used to do arbitrary things with this value. While the pinch gesture is being performed, it is continuously multiplied by <a href="qml-qtquick-pinchhandler.html#activeScale-prop">activeScale</a>; after the gesture ends, it stays the same; and when the next pinch gesture begins, it begins to be multiplied by <a href="qml-qtquick-pinchhandler.html#activeScale-prop">activeScale</a> again.</p>
</div></div><!-- @@@scale -->
<br/>
<!-- $$$translation -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="translation-prop">
<td class="tblQmlPropNode"><p>
<a name="translation-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">translation</span> : <span class="type">QVector2D</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The translation of the gesture <a href="qml-qtquick-pinchhandler.html#centroid-prop">centroid</a>. It is <code>(0, 0)</code> when the gesture begins.</p>
</div></div><!-- @@@translation -->
<br/>
<!-- $$$xAxis -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="even" id="xAxis-prop"><th class="centerAlign"><p><a name="xAxis-prop"></a><b>xAxis group</b></p></th></tr><tr valign="top" class="odd" id="xAxis.minimum-prop"><td class="tblQmlPropNode"><p><a name="xAxis.minimum-prop"></a><span class="name">xAxis.minimum</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr><tr valign="top" class="odd" id="xAxis.maximum-prop"><td class="tblQmlPropNode"><p><a name="xAxis.maximum-prop"></a><span class="name">xAxis.maximum</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr><tr valign="top" class="odd" id="xAxis.enabled-prop"><td class="tblQmlPropNode"><p><a name="xAxis.enabled-prop"></a><span class="name">xAxis.enabled</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr></table></div></div><div class="qmldoc"><p><code>xAxis</code> controls the constraints for horizontal translation of the <a href="../qmake/qmake-variable-reference.html#target">target</a> item.</p>
<p><code>minimum</code> is the minimum acceptable x coordinate of the translation. <code>maximum</code> is the maximum acceptable x coordinate of the translation. If <code>enabled</code> is true, horizontal dragging is allowed.</p>
</div></div><!-- @@@xAxis -->
<br/>
<!-- $$$yAxis -->
<div class="qmlitem"><div class="qmlproto"><div class="table"><table class="qmlname"><tr valign="top" class="even" id="yAxis-prop"><th class="centerAlign"><p><a name="yAxis-prop"></a><b>yAxis group</b></p></th></tr><tr valign="top" class="odd" id="yAxis.minimum-prop"><td class="tblQmlPropNode"><p><a name="yAxis.minimum-prop"></a><span class="name">yAxis.minimum</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr><tr valign="top" class="odd" id="yAxis.maximum-prop"><td class="tblQmlPropNode"><p><a name="yAxis.maximum-prop"></a><span class="name">yAxis.maximum</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr><tr valign="top" class="odd" id="yAxis.enabled-prop"><td class="tblQmlPropNode"><p><a name="yAxis.enabled-prop"></a><span class="name">yAxis.enabled</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr></table></div></div><div class="qmldoc"><p><code>yAxis</code> controls the constraints for vertical translation of the <a href="../qmake/qmake-variable-reference.html#target">target</a> item.</p>
<p><code>minimum</code> is the minimum acceptable y coordinate of the translation. <code>maximum</code> is the maximum acceptable y coordinate of the translation. If <code>enabled</code> is true, vertical dragging is allowed.</p>
</div></div><!-- @@@yAxis -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
